<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.goods_id">
                <router-link :to="'/home/newsinfo/' + item.store_id +'/' + item.goods_id">
                    <img class="mui-media-object mui-pull-left" :src="item.goods_image">
                    <div class="mui-media-body">
                        <h1>{{ item.goods_name }}</h1>
                        <p class='mui-ellipsis'>
                            <!--<span>发表时间: {{ item.add_time | dateFormat('YYYY-MM-DD') }}</span>-->
                            <span>价格: {{ item.goods_price }}</span>
                            <span>店铺: {{ item.store_name}}</span>
                        </p>
                    </div>
                </router-link>
            </li>

        </ul>
    </div>
</template>

<script type="text/ecmascript-6">

    import { Toast } from 'mint-ui'

    export default {
        name: 'NewsList',
        data() {
            return {
                newsList: [],//新闻列表
            };
        },
        created() {
            this.getNewsList();
        },
        methods: {

            getNewsList() {

                var pushData = {
                            barcode : ' ',
                            gc_id : '1985',
                            curpage : 1,
                            b_id : ' ',
                            keyword : ' ',
                            order : '2',
                            key : '1',
                            gc_child_id : '',
                            store_id : '14'
                        }

                //获取新闻列表
                this.$http.post('mobile/index.php?act=goods&op=goods_list',pushData).then(result=> {

                    console.log(result)
                    if(result.body.code == 200){
                        //如果没有失败,应该把数据保存到 data 上
                        this.newsList = result.body.datas

                        Toast('成功')

                    } else {

                        Toast('成获取新闻列表失败!')

                    }
                });
            }
        }
    }
</script>


<style lang="scss" scoped rel="stylesheet/scss">

    .mui-table-view {
        li {
            h1 {
                font-size: 14px;
            }

            .mui-ellipsis {
                font-size: 12px;
                color: #226aff;
                display: flex;
                justify-content: space-between;
            }
        }
    }

</style>